//
//  MNDNewFeatureViewController.m
//  minidai
//
//  Created by 谭谭伟 on 17/3/6.
//  Copyright © 2017年 谭谭伟. All rights reserved.
//

#import "MNDNewFeatureViewController.h"
#import "MNDNewFeatureView.h"
#import "UserDefaultsTool.h"
@interface MNDNewFeatureViewController ()
/* 新特性页 */
@property (strong, nonatomic) MNDNewFeatureView *featureView;

@end

@implementation MNDNewFeatureViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self setupNewFeatureView];
}
#pragma mark -搭建新特性页面
- (void)setupNewFeatureView {
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        NSString *versionKey = @"CFBundleShortVersionString";
        //取到上一次版本号
        NSString *previousVersion = [UserDefaultsTool objetForKey:versionKey];
        //取到当前版本号
        NSString *currentVersion = [NSBundle mainBundle].infoDictionary[versionKey];
        
        //比较版本是否一致
        if ([currentVersion isEqualToString:previousVersion]) {
            [_featureView removeFromSuperview];
            
        } else {
            _featureView = [[MNDNewFeatureView alloc]initWithFrame:self.view.bounds];
            _featureView.backgroundColor = [UIColor yellowColor];
            _featureView.featurePictureArray = @[@"IntroImage1",@"IntroImage2",@"IntroImage3"];
            [self.view addSubview:_featureView];
            
            //保存版本号
            [UserDefaultsTool saveObject:currentVersion forKey:versionKey];
            
        }
    });
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
